package com.dongbing.support.strategy;

import com.alibaba.fastjson2.JSONObject;
import com.dongbing.entity.support.BatchTaskDetailPO;
import com.dongbing.entity.support.BatchTaskPO;
import com.sun.istack.internal.NotNull;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

public abstract class BatchTaskExecutorStrategy {

    private static final List<BatchTaskExecutorStrategy> strategies = new ArrayList<>();

    @PostConstruct
    public void init() {
        strategies.add(this);
    }

    /**
     * 执行调度 执行调度
     * @param task 批量任务PO
     * @param msgBody 消息
     * @return res
     */
    public static List<BatchTaskDetailPO> doExecute(@NotNull BatchTaskPO task, JSONObject msgBody) {
        // TODO 先这样写
        return strategies.get(0).execute(task, msgBody);
    }

    /**
     * 执行调度
     * @param task 批量任务
     * @param msgBody 查询条件
     * @return 明细行
     */
    public abstract List<BatchTaskDetailPO> execute(BatchTaskPO task, JSONObject msgBody);

}

